KERNELDIR := /root/Linux4.1.19/ebf_linux_kernel/
CURRENT_PATH := $(shell pwd)
ARCH = arm
CROSS_COMPILE = arm-linux-gnueabihf-
export ARCH CROSS_COMPILE

# 设置模块名
obj-m := key_driver.o

# 提取模块名（去掉.o后缀）
MODULE_NAME := $(basename $(notdir $(obj-m)))

all:
	$(MAKE) -C $(KERNELDIR) M=$(CURRENT_PATH) modules

.PHONY: clean clean_no_use

clean:
	$(MAKE) -C $(KERNELDIR) M=$(CURRENT_PATH) clean

clean_no_use:
	find $(CURRENT_PATH) -path $(CURRENT_PATH)/refer -prune -o \
	-type f \( ! -name '$(basename $(MODULE_NAME)).c' \
	! -name '$(basename $(MODULE_NAME)).o' \
	! -name '$(basename $(MODULE_NAME)).ko' \
	! -name 'Makefile' \) -exec rm -f {} +
